package com.gem.mapper;

import com.gem.domain.Student;
import com.gem.domain.StudentAPI;
import com.gem.util.ConditionUtil;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Apolar_GuanYH-管阳红
 * Description: 学生Mapper
 * create 2019/11/5 20:51
 * Modified By:
 */
@Mapper
public interface StudentMapper {

    //按班级表ID查询所有学生
    @Select("SELECT stu.*,c.c_id FROM student stu,classinfo c WHERE stu.s_class_id=c.id AND stu.s_class_id = #{classId} AND s_status>0")
    List<Student> selectAllStuByClass(Integer classId);

    //按学生ID查询学生
    @Select("SELECT stu.*,c.c_id FROM student stu,classinfo c WHERE stu.s_class_id=c.id AND stu.s_id = #{sId} AND s_status>0")
    List<Student> selectStuBySid(Integer sId);

    //增加学生
    @Insert("INSERT INTO student VALUES(#{id}, #{s_name},#{s_sex},#{s_sc_name},#{s_major},#{s_CET},#{s_certificate},#{s_education},#{s_graduation},#{s_phone},#{s_qq},#{s_id_number},#{s_telephone},#{s_home},#{s_email},#{s_recruiter},#{c_id},#{s_state},#{statu},#{s_remark})")
    boolean addStu(StudentAPI stuAPI);

    //删除（伪删）学生
    @Update("UPDATE student SET s_status=-1 WHERE s_id=#{sId}")
    boolean deleteStu(Integer sId);

    //修改学生
    @Update("UPDATE student SET s_name=#{s_name},s_gender=#{s_sex},s_school_name=#{s_sc_name},s_major=#{s_major},s_cet=#{s_CET},s_certificate=#{s_certificate},s_education=#{s_education},s_gradtime=#{s_graduation},s_self_tel=#{s_phone},s_qq=#{s_qq},s_id_card=#{s_id_number},s_parent_tel=#{s_telephone},s_address=#{s_home},s_email=#{s_email},s_recruiter=#{s_recruiter},s_class_id=#{c_id},s_state=#{s_state},s_status=#{statu},s_remark=#{s_remark} WHERE s_id=#{id}")
    boolean updateStu(StudentAPI stuAPI);

    //条件查询
    List<Student> selectStuByCondition(ConditionUtil cu);
}
